<template>
  <div class="sort-box" @click="changeSort">
    <div :style="{ cursor: isCursor }">{{ name }}</div>
    <div class="sort-con">
      <div class="s-item" :class="{ active: currentDesc == item.name }" v-for="(item, index) in sortIconList" :key="index">
        <!-- <i :class="`iconfont ${item.icon}`"></i> -->
        <van-icon :name="item.icon" />
        
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'BaseSort',
  props: {
    currentDesc: {
      type: String,
      required: true,
      default: '',
    },
    name: {
      type: String,
      default: '',
    },
    isCursor: {
      type: String,
      default: 'pointer',
    },
  },
  data() {
    return {
      isActive: 0,
      sortIconList: [
        {
          name: 'asc',
          icon: 'arrow-up',
        },
        {
          name: 'desc',
          icon: 'arrow-down',
        },
      ],
    }
  },
  mounted(){
   this.hidtop()
  },
  methods: {
    changeSort(index) {
      this.$emit('changeSort', this.currentDesc)
    },
    hidtop(){
      if(this.name=="相关性"){
        this.sortIconList=[
          {
          name: 'desc',
          icon: 'arrow-down',
        },
          ]
      }
      else{
         this.sortIconList= [
        {
          name: 'asc',
          icon: 'arrow-up',
        },
        {
          name: 'desc',
          icon: 'arrow-down',
        },
      ]
      }
    }
  },
  created() {},
  watch: {},
}
</script>

<style lang="scss" scoped>
.sort-box {
  display: flex;
  align-items: center;
}
.sort-con {
  .s-item {
    cursor: pointer;
    position: relative;

    i {
      font-size: 16px;
    }
    &.active {
      i {
        color: #67e5ff;
      }
    }
  }
  .s-item:first-child {
    height: 14px;
  }
.sort-con{
  margin-top: 5px;
}
}


.sort-con :nth-child(2){
    margin-top: -5px;
}
</style>
